using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_ITEMPRICELISTMap : EntityTypeConfiguration<SO_ITEMPRICELIST>
    {
        public SO_ITEMPRICELISTMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.ITEM_ID, t.ITEM_DESC, t.LIST_NAME, t.TYPE_NAME });

            // Properties
            this.Property(t => t.CRITERIA)
                .HasMaxLength(20);

            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ITEM_ID)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.ITEM_DESC)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.LIST_NAME)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.TYPE_NAME)
                .IsRequired()
                .HasMaxLength(25);

            // Table & Column Mappings
            this.ToTable("SO_ITEMPRICELIST");
            this.Property(t => t.CRITERIA).HasColumnName("CRITERIA");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.ITEM_ID).HasColumnName("ITEM_ID");
            this.Property(t => t.ITEM_DESC).HasColumnName("ITEM_DESC");
            this.Property(t => t.LIST_NAME).HasColumnName("LIST_NAME");
            this.Property(t => t.TYPE_NAME).HasColumnName("TYPE_NAME");
            this.Property(t => t.COF).HasColumnName("COF");
            this.Property(t => t.OR).HasColumnName("OR");
            this.Property(t => t.ARE).HasColumnName("ARE");
        }
    }
}
